package com.ysd.lis.controller;


import com.ysd.common.Result;
import com.ysd.common.dto.DeleteDto;
import com.ysd.lis.controller.pub.BaseController;
import com.ysd.lis.entity.TDictionaryType;
import com.ysd.lis.service.TDictionaryTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 委托单位表 前端控制器
 * </p>
 *
 * @author Peng
 * @since 2021-10-20
 */
@RestController
    @RequestMapping("/api/sys")
public class TDictionaryTypeController extends BaseController {
    @Autowired
    TDictionaryTypeService tDictionaryTypeService;

    @GetMapping("/getDictionaryType")
    public Result getDictionaryType() {
        List<TDictionaryType> list = tDictionaryTypeService.list();
        return Result.succ(1, "查询成功", list);
    }

    @PostMapping("/addDictionaryType")
    public Result addDictionaryType(@RequestBody TDictionaryType tDictionaryType) {
        boolean save = tDictionaryTypeService.save(tDictionaryType);
        if (save) {
            return Result.succ(1, "添加成功", "");
        } else {
            return Result.succ(400, "添加失败", "");
        }
    }
    @PostMapping("/editDictionaryType")
    public Result editDictionaryType(@RequestBody TDictionaryType tDictionaryType) {
        boolean b = tDictionaryTypeService.updateById(tDictionaryType);
        if (b) {
            return Result.succ(1, "修改成功", "");
        } else {
            return Result.succ(400, "修改失败", "");
        }
    }
    @PostMapping("/removeDictionaryType")
    public Result removeDictionaryType(@RequestBody DeleteDto deleteDto) {
        boolean b = tDictionaryTypeService.removeById(deleteDto.getId());
        if (b) {
            return Result.succ(1, "删除成功", "");
        } else {
            return Result.succ(400, "删除失败", "");
        }
    }
}
